import { Injectable } from "@nestjs/common";
import { JwtService } from "@nestjs/jwt";

@Injectable()
export class AuthService {
  constructor(private readonly jwtService: JwtService) {}

  async validateUser(username: string, pass: string): Promise<any> {
    if (username === "atom.hu" && pass === "123456") {
      return {
        name: "atom.hu",
        age: 18,
      };
    }
    return null;
  }

  async login(user: any) {
    const payload = {
      username: user.username,
      id: user.userId,
      companyId: "41f87c58-e041-4cfe-b30f-6e02ca3730af",
    };
    return {
      access_token: this.jwtService.sign(payload),
    };
  }

  async sign(a) {
    return this.jwtService.sign(a);
  }
}
